/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package titanisu.basicMathModule1.integerLessthanGreaterthan;

import titanisu.basicMathModule1.DecimalMultAndDivby10mult.*;
import com.sun.script.javascript.RhinoScriptEngine;
import java.util.ArrayList;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptException;

/**
 *
 * @author Balaji
 */
public class QuestionGeneratorAddSub {

    ArrayList quest = new ArrayList();
    boolean intQ = false;

    private void setQ(ArrayList arlst) {
        this.quest = arlst;
    }

    public ArrayList getQuest() {
        return quest;
    }

    public void setQuest(ArrayList quest) {
        this.quest = quest;
    }

    /*
     * Generates a single question in below format is forms and array with question and nominator and denominator
     * The final the arraylist is put in variable quest and this methog returns a string putting forward only question
     * quest.get(0) question string
     * quest.get(1) answer nominator
     * quest.get(0) answer denominator
     * 
     * @param: void
     * @returns : String having question
     */
    public String getQuestions() {
        try {
            int x = new Random().nextInt(999);
            int y = new Random().nextInt(998) + 1;

//            String op = new titanisu.templates.helperClasses.VariablesHelper().getRandomOperator("X/");

            if (Math.random() > .5) {
                x *= -1;
            }

            if (Math.random() > .5) {
                y *= -1;
            }

            quest.add(0, x + " " + "[__]" + " " + y);

            if (x < y) {
                quest.add(1, "Less Than or <");
            } else if (x > y) {
                quest.add(1, "Greater Than or >");
            } else if (x == y) {
                quest.add(1, "Equals or =");
            }

            setQ(quest);
            //        System.out.println(" quest set in questionGenerator is " + quest);

        } catch (Exception ex) {
            Logger.getLogger(QuestionGeneratorAddSub.class.getName()).log(Level.SEVERE, null, ex);
        }

        System.out.println(" the quest is " + quest);
        return (String) quest.get(0);
    }

    /**
     * Gives the answers
     *
     * @return
     */
    public String getAnswer() {
        String answer = "";
        String den = (String) quest.get(1);
        return answer;
    }

    void setIntegers(boolean b) {
        intQ = b;
    }
}
